import 'package:flutter/material.dart';
import 'package:my_first_app/one_ui_nested_scroll_view.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'One UI Sliver AppBar',
      theme: ThemeData(useMaterial3: true),
      home: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      // appBar: AppBar(
      //   backgroundColor: Colors.blue,
      // ),
      body: OneUiNestedScrollView(
        // expandedHeight: 100,
        // toolbarHeight: 60
        // ignore: prefer_const_constructors
        expandedWidget: Text(
          "你好，李泽民",
          // ignore: prefer_const_constructors
          style: TextStyle(fontSize: 30),
        ),
        // ignore: prefer_const_constructors
        collapsedWidget: Text(
          "你好，李泽民",
          // ignore: prefer_const_constructors
          style: TextStyle(fontSize: 20),
        ),
        leadingIcon: IconButton(
          onPressed: () {},
          icon: const Icon(Icons.menu),
        ),
        actions: [
          IconButton(onPressed: () {}, icon: Icon(Icons.more_vert)),
          IconButton(onPressed: () {}, icon: Icon(Icons.search)),
          IconButton(onPressed: () {}, icon: Icon(Icons.add))
        ],
        sliverList: SliverList(delegate:
            SliverChildBuilderDelegate((BuildContext context, int index) {
          return ListTile(
            leading: CircleAvatar(backgroundColor: Colors.grey.shade300),
            title: Text('Contact $index'),
          );
        })),
        // ignore: prefer_const_constructors
        boxDecoration: BoxDecoration(
            // ignore: prefer_const_constructors
            gradient: LinearGradient(colors: [Colors.blue, Colors.amber])),
      ),
    );
  }
}
